package cn.com.sueframe.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
/**
 * 系统语言转换拦截器，在语言切换前，用来清除浏览器缓存
 * @author anmin
 * Create 2013-3-21
 */
public class SwitchFilter implements Filter {

	@Override
	public void destroy() {}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain filterChain) throws IOException, ServletException {
		HttpServletResponse httpResponse = (HttpServletResponse)response;//假如拦截到得请求时转换语言请求，则清空缓存
		httpResponse.setHeader("Cache-Control", "no-cache");
		httpResponse.setDateHeader("Expires", 0);
		httpResponse.setHeader("Pragma", "No-cache");
        filterChain.doFilter(request, httpResponse);
	}

	@Override
	public void init(FilterConfig config) throws ServletException {}

}
